package com.xwh.week5;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Pr_5 {
    static long[] array5=new long[100000];
    static long[] array6=new long[100000];
    static List<Long> list=new ArrayList<>();
    static HashMap<Long,Long> hashMap=new HashMap<>();
    public static void main(String[] args) {
        function();
        int fast=165;
        int slow=145;
        while (true){
            if(array5[fast]==array6[slow]){
                System.out.println(array6[slow]);
                break;
            }else if(array5[fast]<array6[slow]){
                fast++;
            }else {
                slow++;
            }
        }
    }
    public static void function(){
        for(long i=1;i<100000;i++){
            array5[(int)i]=i*(3*i-1)/2;//165--40755;
//            if(array5[(int)i]==40755){
//                System.out.println(i);
//            }
            array6[(int)i]=i*(2*i-1);//143--40755;
//            hashMap.put(array6[(int)i],i);
//            if(array6[(int)i]>40700&&array6[(int)i]<50000){
//                System.out.println(i+" "+array6[(int)i]);
//            }
//            list.add(i*(2*i)-1);
        }
    }
}
